# $Id: PKGBUILD 77310 2012-10-08 15:54:38Z lfleischer $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Roman Kyrylych <roman@archlinux.org>
# Contributor: Sven Kauber <celeon@gmail.com>
# Contributor: tardo <tardo@nagi-fanboi.net>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=partimage
pkgver=0.6.9
pkgrel=3
pkgdesc='Partition Image saves partitions in many formats to an image file.'
arch=('i686' 'x86_64')
url='http://www.partimage.org/'
license=('GPL')
depends=('libnewt' 'lzo' 'bzip2' 'openssl')
backup=('etc/partimaged/partimagedusers')
install='partimage.install'
source=("http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.bz2"
        'partimage-0.6.9-zlib-1.2.6.patch'
        'partimaged'
        'partimaged-gencrt'
        'partimaged.service')
md5sums=('1bc046fd915c5debbafc85729464e513'
         '202c4334766041d98c5f67c9d62c3063'
         'f3b517a62de5540f3b1a8b7edf65b7ec'
         '2316b116227b07efb48266e660ca1ba1'
         '4102983fdf6e7af7cac73fdf9d37a6f6')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -i ../partimage-0.6.9-zlib-1.2.6.patch

  ./configure --prefix=/usr --sysconfdir=/etc --enable-pam
  make
  make pamfile
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install

  install -Dm0644 partimaged.pam "${pkgdir}/etc/pam.d/partimaged"
  install -Dm0755 "${srcdir}/partimaged" "${pkgdir}/etc/rc.d/partimaged"
  install -Dm0755 "${srcdir}/partimaged-gencrt" "${pkgdir}/usr/bin/partimaged-gencrt"
  chmod 644 "${pkgdir}/etc/partimaged/partimagedusers"

  install -Dm0755 ../partimaged.service "${pkgdir}/usr/lib/systemd/system/partimaged.service"
}
